﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Xamarin.Forms;

namespace WebService {
    // Learn more about making custom code visible in the Xamarin.Forms previewer
    // by visiting https://aka.ms/xamarinforms-previewer
    [DesignTimeVisible(false)]
    public partial class MainPage : ContentPage {
        public MainPage() {
            InitializeComponent();
        }

        private async void CallWebServiceButton_OnClicked(object sender,
            EventArgs e) {
            var httpClient = new HttpClient();
            var response =
                await httpClient.GetAsync("https://v2.jinrishici.com/token");
            var json = await response.Content.ReadAsStringAsync();
            var token = JsonConvert.DeserializeObject<JinrishiciToken>(json);
            ResultLabel.Text = token.data;
        }
    }

    public class JinrishiciToken {
        public string status { get; set; }
        public string data { get; set; }
    }
}